package com.sgb.kjwl.view.ui.adapter.material;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.Bean;
import com.swgk.core.util.UiUtil;

import java.util.List;


/**
 * 作者:张磊
 * 日期:2021/3/20
 * 说明:图片选择
 */
public class PhotoAdapter extends BaseItemDraggableAdapter<Bean, BaseViewHolder> {

    public PhotoAdapter(List<Bean> beans) {
        super(R.layout.photo_adapter, beans);
    }

    @Override
    protected void convert(BaseViewHolder helper, final Bean item) {
        helper.addOnClickListener(R.id.iv_delete).addOnClickListener(R.id.rl_add).setVisible(R.id.iv_pic, !item.isAdd).setVisible(R.id.rl_add, item.isAdd).setVisible(R.id.iv_delete, !item.isAdd);
        ImageView iv_pic = helper.getView(R.id.iv_pic);
        Glide.with(UiUtil.getContext()).load(item.url).apply(RequestOptions.centerCropTransform().centerCrop()).into(iv_pic);
    }
}
